import logging
import os

from selenium.webdriver.common.by import By
import time
from Base.Base import Base


class Page(Base):
    # 定位方法
    text_loc = (By.ID, 'chat-textarea')
    sub_loc = (By.ID, 'chat-submit-button')
    by1 = (By.XPATH, '/html/body/div[3]/div[3]/div[1]/div[1]/table/tbody/tr/td/div[1]/div/ul/li/div/div/div/span[1]')

    def love_text(self, txt):
        self.send_keys(self.text_loc, txt)

    def love_cli(self):
        self.click(self.sub_loc)

    def love_dy1(self):
        var = self.find_selent(self.by1).text
        return var

    # 调用执行方法
    def love_go(self, txt):
        self.open_url(os.getenv('bd_url'))
        logging.info('打开百度')
        self.waitsp(2)
        logging.info('调用等待方法')
        self.love_text(txt)
        logging.info("输入我喜欢软件测试")
        self.love_cli()
        logging.info('点击搜索')
        print(self.love_dy1())
        self.waitsp(9)
